<?php
/** @var yii\data\ArrayDataProvider $dataProvider */
use yii\helpers\Html;
use yii\helpers\Url;

$this->title = '分组';
$this->params['breadcrumbs'][] = $this->title;
?>
<p class="text-right">
    <?= Html::a('创建分组', ['create'], ['class' => 'btn btn-primary']) ?>
</p>
<?php
echo \yii\grid\GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        'id',
        'name',
        'count',
        [
            'class' => \yii\grid\ActionColumn::className(),
            'template' => '{update} {delete}',
            'buttons' => [
                'update' => function($url, $model, $key) {
                    if (in_array($model['id'], [0, 1, 2])) {
                        return '';
                    }
                    return Html::a('<i class="glyphicon glyphicon-pencil"></i>', ['update', 'id' => $model['id']], ['title' => '更新']);
                },
                'delete' => function($url, $model, $key) {
                    if (in_array($model['id'], [0, 1, 2])) {
                        return '';
                    }
                    return Html::a('<i class="glyphicon glyphicon-trash"></i>', ['delete', 'id' => $model['id']], ['title' => '删除', 'data-method' => 'post', 'data-confirm' => '确定要删除这个分组吗?']);
                }
            ]
        ]
    ]
]);
